// These are meant to be typed into the REPL. You can also run
// scala -Xnojline < 01_readline.sc to run them all at once.

import scala.io.Source

// 要么通过该方式、要么使用绝对路径
val path = Thread.currentThread().getContextClassLoader.getResource("mary.txt").getPath

val source = Source.fromFile(path, "UTF-8")
//val source = Source.fromFile("C:\\Users\\bart\\app\\spaces\\gitee\\scala_repo\\scala-practice\\src\\main\\scala\\com\\bart\\scala\\ch13\\sec01\\mary.txt", "UTF-8")
val lineIterator = source.getLines

for (l <- lineIterator) 
  println(if (l.length <= 13) l else l.substring(0, 10) + "...")

source.close()

// Caution: The sources below aren't closed.

val lines = Source.fromFile(path, "UTF-8").getLines.toArray

val contents = Source.fromFile(path, "UTF-8").mkString


